<?php

require_once('db/db.php');

$db=new DB;

function check($name){
	if(isset($_REQUEST[$name])){
		return $_REQUEST[$name];
	}
	else{
		die();
	}
}

$id=intval(check('id'));
$location=check('location');
$ad_link=check('ad_link');
$pic_link=check('pic_link');
$desc=check('desc');
$weight=intval(check('weight'));

$sql = "update `ad` set `location`='$location', `ad_link`='$ad_link', `pic_link`='$pic_link', `desc`='$desc', `weight`=$weight where `id`=$id";

if(!$db->query($sql)){
	return false;
}

echo json_encode(array(
	'id' => $id,
	'location' => $location,
	'ad_link' => $ad_link,
	'pic_link' => $pic_link,
	'desc' => $desc,
	'weight' => $weight
));

?>
